<template>
  <div>
    <p>用户名:<input type="text" v-model="username"></p>
    <p>密码:<input type="text" v-model="password"></p>
    <p>确认密码:<input type="text" v-model="password1"></p>
    <p>头像：<input type="file" id="img"></p>
    <p>标题：<input type="text" v-model="name"></p>
    <p><button @click="btn">添加</button></p>
  </div>

</template>

<script>
    export default {
        name: "Register",
        data(){
          return{
            username:'',
            password:'',
            password1:'',
            name:'',
            list:[]
          }
        },
        methods:{
          btn(){
            var head_portrait=document.getElementById('head_portrait').files[0]
            let form_data=new FormData()
            form_data.append('username',this.username)
            form_data.append('password',this.password)
            form_data.append('password1',this.password1)
            form_data.append('name',this.name)
            form_data.append('img',img)
            axios({
              url:'http://127.0.0.1:8000/app01/register/',
              method:'post',
              data:form_data
            }).then(res=>{
              console.log(res)
            })
          }
        },
        created() {
        }
    }
</script>

<style scoped>

</style>